function lookup = pcc2(N,K,designSNRdB,pi)
% Construct using Bhattacharyya parameter based construction,
% at "design-SNR" := (Ec/N0) = (SNR_OF_AWGN/2), given in dB
%

z = zeros(N,1);
designSNR = 10^(designSNRdB/10);
z(1) = -designSNR; % In logdomain: actual initial Bh.Param = exp(-Ec/N0)


for lev=1:log2(N)
    B=2^(1+pi(log2(N)-lev+1));
    for l=0:fix(N/B) -1 
        for j=0:fix(B/2) - 1
            T = z(j + B*l + 1);
            z(j + B*l + 1) = logdomain_diff( log(2)+T, 2*T );  %  2z - z^2
            z(B*l + fix(B/2) + j + 1) = 2*T;                        %  z^2
        end
    end
end


[~,indices] = sort(z,1,'ascend');  %default sort is "Ascending"; 
                            % 1 refers to sort "columns" (not rows)

lookup = zeros(N,1);
for j=1:K 
    lookup(indices(j)) = -1; %locations in z containing least K values
end

end